<template>
  <el-card>
    <!-- 查询区域 -->
    <el-form :inline="true" :model="Form" class="demo-form-inline">
      <el-form-item label="工单号">
        <el-input v-model="Form.number" placeholder="请输入工单号"></el-input>
      </el-form-item>
      <el-form-item label="标题">
        <el-input v-model="Form.title" placeholder="请输入标题"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="Search_data(Form)">查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格区域 -->
    <el-table :data="sys_search" border stripe style="width: 100%">
      <el-table-column
        fixed
        type="index"
        label="#"
        width="80"
      ></el-table-column>
      <el-table-column
        prop="number"
        label="工单号"
        width="120"
      ></el-table-column>
      <el-table-column prop="title" label="标题" width="200"></el-table-column>
      <el-table-column
        prop="difficulty"
        label="难度"
        sortable
        align="center"
        width="180"
      >
        <template v-slot="scope">
          <el-rate v-model="scope.row.difficulty" disabled></el-rate>
        </template>
      </el-table-column>
      <el-table-column prop="schedule" label="进度" sortable>
        <template v-slot="scope">
          <el-progress
            :percentage="scope.row.schedule"
            :status="status(scope.row.schedule)"
          ></el-progress>
        </template>
      </el-table-column>
      <el-table-column
        prop="receive"
        label="归属"
        width="120"
      ></el-table-column>
      <el-table-column prop="submit" label="发布" width="100"></el-table-column>
      <el-table-column prop="date" label="发布日期"></el-table-column>
      <el-table-column prop="status" label="状态" sortable width="100">
        <template v-slot="scope">
          <el-tag type="success" size="small" v-if="scope.row.status === 0"
            >待接取</el-tag
          >
          <el-tag type="danger" size="small" v-else-if="scope.row.status === 1"
            >进行中</el-tag
          >
          <el-tag type="info" size="small" v-else>已完成</el-tag>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template v-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >查看</el-button
          >
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      Form: {
        number: '',
        title: ''
      },
      search: {
        number: '',
        title: ''
      },
      sys: [
        // 字符串是字符串，数字是数字，不能混淆
        {
          id: '1',
          number: '10001',
          title: '寻找有缘人',
          difficulty: 5,
          schedule: 50,
          receive: '月老',
          submit: 'chalk',
          date: '2020/2/2',
          status: 0
        },
        {
          id: '2',
          number: '10002',
          title: '寻找倒霉人',
          difficulty: 3,
          schedule: 100,
          receive: '月老',
          submit: 'chalk',
          date: '2020/2/3',
          status: 1
        }
      ]
    }
  },
  methods: {
    // 进度条
    status(e) {
      if (e === 100) {
        return 'success'
      }
    },
    Search_data(e) {
      this.search = e
    }
  },
  computed: {
    sys_search() {
      return this.sys.filter((data) => data.number.toLowerCase().includes(this.search.number.toLowerCase()) && data.title.toLowerCase().includes(this.search.title.toLowerCase())
      )
    }
  }
}
</script>
<style lang="less" scoped>
.el-card {
  position: relative;
  height: 90%;
  text-align: center;
  // background: url(../assets/img/cen.jpg) no-repeat center #fff;
  background-size: contain;
  margin: 20px 0 0;
}
</style>
